import http from '@/utils/request.js'

export default {
	state: {
		warehouses: uni.getStorageSync('warehouses') ? uni.getStorageSync('warehouses') : [],
		salespersons: uni.getStorageSync('salespersons') ? uni.getStorageSync('salespersons') : [],
	},
	mutations: {
		SET_warehouses(state, warehouses) {
			state.warehouses = warehouses;
			uni.setStorageSync('warehouses', warehouses);
		},
		SET_salespersons(state, salespersons) {
			state.salespersons = salespersons;
			uni.setStorageSync('salespersons', salespersons);
		},
	},
	actions: {
		InitDict(store, loginForm) {
			http.get("/wms/warehouse/list").then((res) => {
				store.commit("SET_warehouses", res.rows)
			})
			http.get("/wms/common/list/user").then((res) => {
				store.commit("SET_salespersons", res.userList)
			})
		},

	},
};